#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;
const int MOD = 998244353;

ll cmb(ll n) { return n * (n - 1) / 2 % MOD; }
ll fastpow(ll b, ll p) {
  ll res = 1;
  while (p) {
    if (p & 1) res = res * b % MOD;
    b = b * b % MOD;
    p >>= 1;
  }
  return res;
}
ll f(ll a, ll b) {
  ll res = 0;
  rep(i, 0, 29) {
    int c1 = (a >> i) & 1;
    int c2 = (b >> i) & 1;
    ll prea = a >> (i + 1);
    ll preb = b >> (i + 1);
    if (!c1 && !prea) continue;
    if (!c2 && !preb) continue;
    // the bits diff from here
    int mask = 1 << i;
    ll p1 = prea * mask % MOD;
    if (c1) p1 = (p1 + ((a & (mask - 1)) + 1)) % MOD;
    ll p2 = preb * mask % MOD;
    if (c2) p2 = (p2 + ((b & (mask - 1)) + 1)) % MOD;
    ll x = p1 * p2 % MOD * mask % MOD;
    res = (res + x) % MOD;
  }
  return res;
}
void solve() {
  ll n, m, a, b;
  cin >> n >> m >> a >> b;
  ll s1 = (fastpow(2, n) - 2 + MOD) % MOD;
  ll s2 = (fastpow(2, m) - 2 + MOD) % MOD;
  ll sum = 0;
  // 00 - 00
  sum = (sum + (a + 1) * (b + 1) % MOD) % MOD;
  // 01 - 00 && 00 - 01
  sum = (sum + cmb(a + 1) * s1 % MOD * (b + 1) % MOD) % MOD;
  sum = (sum + cmb(b + 1) * s2 % MOD * (a + 1) % MOD) % MOD;
  // 01 - 01
  sum = (sum + s1 * s2 % MOD * f(a, b) % MOD) % MOD;
  cout << sum << endl;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}